package com.neusoft.aclome.cmp.cloud.server.jcce.controller;

import com.alibaba.fastjson.JSONObject;
import com.neusoft.aclome.cmp.cloud.server.jcce.dto.request.CloudPlatConsRequest;
import com.neusoft.aclome.cmp.cloud.server.jcce.dto.response.CloudPlatformConsultDTO;
import com.neusoft.aclome.cmp.cloud.server.jcce.dto.response.ConsultGraph;
import com.neusoft.aclome.cmp.cloud.server.jcce.service.CloudPlatformConsultService;
import com.neusoft.aclome.cmp.cloud.server.pub.cloud.constants.PubApi;
import com.neusoft.aclome.cmp.common.model.vo.HttpResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

/**
 * describe :
 *
 * @author hao.dd
 * @date 2024/2/4
 */
@Api("CloudPlatformConsultController")
@RequestMapping("/jcce" + PubApi.VERSION + "/consult")
@RestController
public class CloudPlatformConsultController {

    @Autowired
    private CloudPlatformConsultService cloudPlatformConsultService;

    @GetMapping("list")
    @ApiOperation(value = "查询列表", notes = "list")
    public HttpResponse list(CloudPlatConsRequest request) {
        return HttpResponse.resultSuccess(cloudPlatformConsultService.pageList(request));
    }


    @PostMapping()
    @ApiOperation(value = "创建", notes = "create")
    public HttpResponse create(CloudPlatformConsultDTO request) {
        cloudPlatformConsultService.create(request);
        return HttpResponse.resultSuccess();
    }

    @PutMapping()
    @ApiOperation(value = "修改", notes = "update")
    public HttpResponse update(@RequestBody CloudPlatformConsultDTO request) {
        cloudPlatformConsultService.update(request);
        return HttpResponse.resultSuccess();
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除", notes = "delete")
    public HttpResponse delete(@PathVariable Integer id) {
        cloudPlatformConsultService.delete(id);
        return HttpResponse.resultSuccess();
    }

    @PostMapping("/createConsult")
    @ApiOperation(value = "创建磋商任务", notes = "创建磋商任务")
    public HttpResponse createConsult(CloudPlatformConsultDTO request) {
        ConsultGraph graph = cloudPlatformConsultService.createConsult(request);
        return HttpResponse.resultSuccess(graph);
    }

    @ApiOperation(value = "查询磋商前后的资源数量", notes = "查询磋商前后的资源数量，注明：其中的数量都是假数据")
    @GetMapping("/cloudType/{cloudType}/id/{id}")
    public HttpResponse getConsultResourceCount(@PathVariable String cloudType, @PathVariable Integer id) {
        return HttpResponse.resultSuccess(cloudPlatformConsultService.getConsultResourceCount(cloudType, id));
    }
}
